﻿using System;

namespace Entities
{
    [Serializable]
    public class tblCoupon
    {
        private string coupon_name;
        private string coupon_des;
        private int discount;
        private int coupon_num;
        private DateTime date_start;
        private DateTime date_end;
        private DateTime date_added;

        public tblCoupon() {}

        public tblCoupon(string coupon_name, string coupon_des, int discount, int coupon_num, DateTime date_start, DateTime date_end, DateTime date_added)
        {
            this.coupon_name = coupon_name;
            this.coupon_des = coupon_des;
            this.discount = discount;
            this.coupon_num = coupon_num;
            this.date_start = date_start;
            this.date_end = date_end;
            this.date_end = date_added;
        }

        public string couponName
        {
            get { return this.coupon_name; }
            set
            {
                if (value == null)
                    throw new Exception("Tên khuyến mại không được để trống!");
                this.coupon_name = value;
            }
        }

        public string couponDes
        {
            get { return this.coupon_des; }
            set
            {
                this.coupon_des = value;
            }
        }

        public int Discount
        {
            get { return this.discount; }
            set
            {
                if (value == null)
                    throw new Exception("Số tiền được khuyến mại không được để trống!");
                this.discount = value;
            }
        }

        public int couponNum
        {
            get { return this.coupon_num; }
            set
            {
                if (value == null)
                    throw new Exception("Số lượng khuyến mại không được để trống!");
                this.coupon_num = value;
            }
        }

        public DateTime dateStart
        {
            get { return this.date_start; }
            set
            {
                this.date_start = value;
            }
        }

        public DateTime dateEnd
        {
            get { return this.date_end; }
            set
            {
                this.date_end = value;
            }
        }

        public DateTime dateAdded
        {
            get { return this.date_added; }
            set
            {
                this.date_added = value;
            }
        }

        public override string ToString()
        {
            return this.coupon_name + "; " + this.coupon_des + "; " + this.discount + "; " + this.coupon_num + "; " + this.date_start + "; " + this.date_end + "; " + this.date_added + "; ";
	    }
	    public override bool Equals(Object obj)
	    {
            tblCoupon me = (tblCoupon)obj;
	        bool ret=this.couponName.Equals(me.couponName);
	        return ret;
	    }
	    public override int GetHashCode()
	    {
	        return this.couponName.GetHashCode();
	    }

    }
}
